package com.gupao.ldr.pattern.strategy.pay;

import strategy.pay.payport.PayType;

public class Order {

    private String uid;
    private String orderId;
    private double amount;

    public Order(String uid, String orderId, double amount) {
        this.uid = uid;
        this.orderId = orderId;
        this.amount = amount;
    }

    //完美解决了switch的过程，不需要代码逻辑中写suitch了
    //更不需要写if else fi
    public PayState pay(PayType payType){

        return payType.get().pay(this.uid,this.amount);
    }


    public static void main(String[] args) {
        //省略把商品添加到购物车，再从购物车下单
        //直接从订单开始
        Order order=new Order("1","201803110010000009",324.35);
        //开始支付，微信支付，支付宝，银联支付，京东白条，财付通
        //每个渠道它支付的具体算法是不一样的
        //基本算法是固定的

        System.out.println(order.pay(PayType.UNION_PAY));

    }
}
